/**
 * @Description:
 * @author 若琳
 * @date 2021/8/14
*/

const express = require('express');
const UserLogController = express.Router();

const CommonService = require("../../../../../../../../ruoling-system/src/com/ruoling/system/service/v1/common/service.common.js");

const UserLogService = require("../../../../../../../../ruoling-system/src/com/ruoling/system/service/v1/monitor/service.userlog.js");
//数据集合
const ResultJson = require("../../../../../../../../ruoling-model/src/com/ruoling/model/SystemModel/ResultJson.js").V("v1.0.0");
const LayuiGrid = require("../../../../../../../../ruoling-model/src/com/ruoling/model/SystemModel/layuiGrid.js");


/**
 * 登录日志列表视图
 */
UserLogController.get("/monitor/loginlog/list/view",function (Request,response){

    response.type(".html");
    response.render("admin/monitor/userlog/loginlog.html");
    return;
});


/**
 * 登录日志列表
 */
UserLogController.get("/v1/api/monitor/loginlog/list",function (Request,response){

    try{
        let {limit,page,sys_login_state,start_time,end_time} = Request.query;
        UserLogService.UserLoginLogListService(limit,page,sys_login_state,start_time,end_time,(err,data)=>{
            if(err){
                response.send(ResultJson.GUBError());
                return;
            }
            response.send(new LayuiGrid(data.pager.totalRecord,data.pager.dataList));
            return;
        });

    }catch (e){
        response.send(ResultJson.SystemError());
        return;
    }
});


module.exports = UserLogController;